﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Payroll.BusinessLogic.CustomerManager;
using PayrollHR.Web;
using Payroll.Common.Utils;
using Payroll.BusinessLogic;
using Payroll.BusinessLogic.Devices;

namespace PayrollHR.Administration.Modules
{
    public partial class VoucherSearchControl : BasePayrollAdministrationUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int UserId = PayrollContext.Current.Session.EmployeeId;
                hfdUserId.Value = CommonHelper.ToString(UserId);
                this.FillVender();
            }
        }
        public void FillVender()
        {
            ddlVendor.Items.Clear();
            ListItem ddlVendorItem0 = new ListItem("----Chọn nhà cung cấp----", "-1");
            ddlVendor.Items.Add(ddlVendorItem0);
            ListItem ddlVendorItem1 = new ListItem("CK", "CK");
            ddlVendor.Items.Add(ddlVendorItem1);
            ListItem ddlVendorItem2 = new ListItem("CK2", "CK2");
            ddlVendor.Items.Add(ddlVendorItem2);
            ListItem ddlVendorItem3 = new ListItem("VINA", "VINA");
            ddlVendor.Items.Add(ddlVendorItem3);           
        }
        public VoucherSearch GetVoucherSearch()
        {
            string vender = null;
            if (ddlVendor.SelectedIndex > 0)
            {
                vender = CommonHelper.ToString(ddlVendor.SelectedItem.Value);
            }
            var voucher = new VoucherSearch
            {
                Taxcode = txtTaxcode.Text.Trim(),
                CompanyName = txtCustomerName.Text.Trim(),
                Vendor = vender,
                StartTime = dpfrom.SelectedDate,
                EndTime = dpTo.SelectedDate,
                Status = rblStatus.SelectedIndex == 0 ? -1 : rblStatus.SelectedIndex - 1
            };
            return voucher;
        }
    }
}